library(tidyverse)
library(maps)
library(mapdata)
library(lubridate)
library(viridis)
library(wesanderson)
library(RColorBrewer)
library(plotly)

Building Maps

Zoom in on US 48 states

# Mapping Data To Shapes

Using R color plates

Wes Anderson

RColorBrewer

## Visualizing Massachusetts Data

Interactive graphs

Exercise

  1. For the above graph “World COVID-19 Confirmed case” summarize the counts for each Country on the graph and update the graph to 9/26/2020. You may need to adjust the size of the points
daily_report<- read_csv(url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/09-26-2020.csv")) %>% 
  rename(Long = "Long_")
## Parsed with column specification:
## cols(
##   FIPS = col_double(),
##   Admin2 = col_character(),
##   Province_State = col_character(),
##   Country_Region = col_character(),
##   Last_Update = col_character(),
##   Lat = col_double(),
##   Long_ = col_double(),
##   Confirmed = col_double(),
##   Deaths = col_double(),
##   Recovered = col_double(),
##   Active = col_double(),
##   Combined_Key = col_character(),
##   Incidence_Rate = col_double(),
##   `Case-Fatality_Ratio` = col_double()
## )
df_09_26_2020 <- daily_report %>% 
  group_by(Country_Region) %>% 
  summarise(Total_Confirmed= sum(Confirmed, na.rm = TRUE), mean_Long= mean(Long, na.rm = TRUE), mean_Lat=mean(Lat, na.rm = TRUE))
## `summarise()` ungrouping output (override with `.groups` argument)
graph_09_26_2020 <- ggplot(data=df_09_26_2020, aes(x= mean_Long, y=mean_Lat, size=Total_Confirmed/(10^5))) +
  borders(database = "world", fill = NA, colour = "grey90")+
  theme_bw()+
  geom_point( shape=21 ,fill= 'purple', alpha= 0.5)+
  labs(title = "World COVID-19 Confirmed Cases", x="", y="",
       size="Cases (x1000)")+
  theme(legend.position = "right")+
  coord_fixed(ratio = 1.5)
  



graph_09_26_2020
## Warning: Removed 2 rows containing missing values (geom_point).

  1. Update Anisa Dhana’s graph layout of the US to 9/26/2020. You may need to adjust the size of the points.
mybreaks <- c(1, 10000, 100000, 1000000, 1000000)
ggplot(daily_report, aes(x=Long, y= Lat, size= Confirmed))+
  borders("state", colour= "white", fill="grey90")+
  geom_point(aes(color=Confirmed), stroke=F, alpha=0.7)+
  scale_size_continuous(name="Cases", trans="log", range=c(1,7), 
                        breaks=mybreaks, labels = c("1-9999",
                        "10000-99999", "1,00000-9,99999", "10,00000-99,99999", "50,00000+"))+
  scale_color_viridis(option = "virids", name= "Cases", trans="log", 
                        breaks=mybreaks, labels = c("1-9999",
                        "10000-99999", "1,00000-9,99999", "10,00000-99,99999", "50,00000+"))+
  theme_void()+
  guides(colour= guide_legend())+
  labs(title= "Anisa Dhana's lagout for COVID-19 Confirmed Cases in the US"
)+
   theme(
      legend.position = "bottom",
      text = element_text(color = "#22211d"),
      plot.background = element_rect(fill = "#ffffff", color = NA), 
      panel.background = element_rect(fill = "#ffffff", color = NA), 
      legend.background = element_rect(fill = "#ffffff", color = NA)
    ) +
    coord_fixed(ratio=1.5)
## Warning in viridisLite::viridis(256, alpha, begin, end, direction, option):
## Option 'virids' does not exist. Defaulting to 'viridis'.
## Warning: Transformation introduced infinite values in discrete y-axis

## Warning: Transformation introduced infinite values in discrete y-axis
## Warning in sqrt(x): NaNs produced
## Warning: Removed 88 rows containing missing values (geom_point).